package com.zzyl.nursing.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.zzyl.nursing.domain.PageBean;
import com.zzyl.nursing.dto.OrdersProjectDto;
import com.zzyl.nursing.mapper.OrdersProjectMapper;
import com.zzyl.nursing.service.OrdersProjectService;
import com.zzyl.serve.domain.NursingProject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrdersProjectServiceImpl implements OrdersProjectService {
    @Autowired
    private OrdersProjectMapper ordersProjectMapper;

    @Override
    public PageBean<NursingProject> page(OrdersProjectDto ordersProjectDto) {
        String name = ordersProjectDto.getName();
        Integer status = ordersProjectDto.getStatus();
        PageHelper.startPage(ordersProjectDto.getPageNum(), ordersProjectDto.getPageSize());
        List<NursingProject> list = ordersProjectMapper.page(name,status);
        Page<NursingProject> page = (Page<NursingProject>) list;
        long total = page.getTotal();
        List<NursingProject> result = page.getResult();

        return new PageBean<>(200, "成功",total,result);
    }

    @Override
    public NursingProject getById(Long id) {

        return ordersProjectMapper.getById(id);
    }
}
